package com.yanqu.road.entity.manor;

import com.yanqu.road.entity.DataObject;

import java.util.ArrayList;
import java.util.List;
/**
 * @author ：zfr
 * @date ：2021/5/10 18:12
 */
public class ManorTechnologyData extends DataObject {
    private long userId;
    private int id;
    private List<Integer> skillLvList;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public List<Integer> getSkillLvList() {
        return skillLvList;
    }

    public void setSkillLvList(List<Integer> skillLvList) {
        this.skillLvList = skillLvList;
        setUpdateOption();
    }

    public void unlockSkill(int pos) {
        if (skillLvList == null) {
            skillLvList = new ArrayList<>();
        }
        if (skillLvList.size() <= pos) {
            int oldSize = skillLvList.size();
            int diff = pos - skillLvList.size() + 1;
            for (int i = 0; i < diff; i++) {
                skillLvList.add(oldSize + i, 0);
            }
        }
        this.skillLvList.set(pos, 1);
        setUpdateOption();
    }

    public void levelUpSkill(int pos) {
        this.skillLvList.set(pos, this.getSkillLvList().get(pos) + 1);
        setUpdateOption();
    }
}
